package com.candy.dao.impl;

import com.candy.dao.AccountDao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Repository;

@Repository
public class AccountDaoImpl implements AccountDao {
    @Autowired
    JdbcTemplate jdbcTemplate;

    @Override
    public void save() {
        System.out.println("账户保存成功");
    }

    @Override
    public void innerMoney(String innerName, double money) {
        jdbcTemplate.update("UPDATE account SET money=money+"+money+" where name='"+innerName+"'");
    }

    @Override
    public void outterMoney(String outterName, double money) {
        jdbcTemplate.update("UPDATE account SET money=money-"+money+" where name='"+outterName+"'");
    }
}
